#ifndef __WPTH_GRADIENTBUTTON_H__
#define __WPTH_GRADIENTBUTTON_H__

#include "defs.h"

class GradientButton;

class GradientButtonEvent : public wxCommandEvent
{
public:
	GradientButtonEvent(wxEventType commandType, int winid)
		: wxCommandEvent(commandType, winid)
		, isDown(false)
		, m_button(NULL)
	{

	}

	void SetButtonObj(GradientButton* obj) { m_button = obj; }
	GradientButton* GetButtonObj() const { return m_button; }

public:
	bool isDown;
protected:
	GradientButton* m_button;
};

class GradientButton : public wxControl
{
	enum
	{
		None = 0,
		HOVER = 1,
		CLICK = 2
	};

public:
	GradientButton() {}

	GradientButton(wxWindow *parent, wxWindowID id,
		const wxGDIImage& bitmap,
		const wxString& label,
		const wxPoint& pos = wxDefaultPosition,
		const wxSize& size = wxDefaultSize, long style = wxNO_BORDER,
		const wxValidator& validator = wxDefaultValidator,
		const wxString& name = wxT("gradientbutton"));

	GradientButton(wxWindow *parent, wxWindowID id,
		const wxString& label,
		const wxPoint& pos = wxDefaultPosition,
		const wxSize& size = wxDefaultSize, long style = wxNO_BORDER,
		const wxValidator& validator = wxDefaultValidator,
		const wxString& name = wxT("gradientbutton"));

	virtual ~GradientButton();

	wxVisualAttributes GetDefaultAttributes() const;
	bool ShouldInheritColours() const { return false; }
	bool Enable(bool enable = true);

	void SetTopStartColour(const wxColour& colour);
	const wxColour& GetTopStartColour() const { return m_topStartColour; }
	void SetTopEndColour(const wxColour& colour);
	const wxColour& GetTopEndColour() const { return m_topEndColour; }
	void SetBottomStartColour(const wxColour& colour);
	const wxColour& GetBottomStartColour() const { return m_bottomStartColour; }
	void SetBottomEndColour(const wxColour& colour);
	const wxColour& GetBottomEndColour() const { return m_bottomEndColour; }
	void SetPressedBottomColour(const wxColour& colour);
	const wxColour& GetPressedBottomColour() const { return m_pressedBottomColour; }
	void SetPressedTopColour(const wxColour& colour);
	const wxColour& GetPressedTopColour() const { return m_pressedTopColour; }

	bool SetForegroundColour(const wxColour& colour);
	void SetDefault();
	void Notify();

protected:
	void OnPaint(wxPaintEvent& event);
	void OnEraseBackground(wxEraseEvent& event);
	void OnSize(wxSizeEvent& event);
	void OnLeftDown(wxMouseEvent& event);
	void OnLeftUp(wxMouseEvent& event);
	void OnMouseLeave(wxMouseEvent& event);
	void OnMouseEnter(wxMouseEvent& event);
	void OnGainFocus(wxFocusEvent& event);
	void OnLoseFocus(wxFocusEvent& event);
	void OnKeyDown(wxKeyEvent& event);
	void OnKeyUp(wxKeyEvent& event);

	bool AcceptsFocus() const;
	wxSize DoGetBestSize() const;
	
	//wxGraphicsPath GetPath(wxGraphicsContext* gc, const wxRect& rc, int r);
	wxColour LightColour(wxColour& colour, int percent);
	void Free();

protected:
	int m_mouseAction;
	wxGDIImage* m_bitmap;
	bool m_hasFocus;
	wxColour m_bottomStartColour;
	wxColour m_bottomEndColour;
	wxColour m_topStartColour;
	wxColour m_topEndColour;
	wxColour m_pressedTopColour;
	wxColour m_pressedBottomColour;

	DECLARE_CLASS(GradientButton)
	DECLARE_EVENT_TABLE()
};

#endif